*** Set working directory ***
cd "C:\..."

*********************** Load Data **********************************************
clear
graph drop _all
cap drop all

use Firm_Level

************************** Setup ***********************************************
sort date

* Merge & Standardize Quarterly MP Shock series
merge m:1 date using fomc_GSW_yields_qtr
drop if _merge != 3
drop _merge
egen mps_std = sd(chg_sveny02)
gen mps = chg_sveny02/mps_std

sort gvkey date
xtset gvkey date

replace invest = invest*100 

*** Sector Codes ***
destring sic, force replace
* Industries are as follows:
*Agriculture, Forestry, Fishing and Hunting = 1
* Mining = 2
* Construction = 3
* Manufacturing = 4
* Transportation, Communications, Electric, Gas and Sanitary = 5
* Wholesale Trade = 6
* Retail Trade = 7
* Finance, Insurance, and Real Estate = 8
* Services = 9
* Government = 10  (there are none in Compustat)
* Other = 11

gen ind = 0
replace ind = 1 if sic >= 100 & sic <= 999
replace ind = 2 if sic >= 1000 & sic <=1499
replace ind = 3 if sic >= 1500 & sic <=1799
replace ind = 4 if sic >= 2000 & sic <=3999
replace ind = 5 if sic >= 4000 & sic <=4999
replace ind = 6 if sic >= 5000 & sic <=5199
replace ind = 7 if sic >= 5200 & sic <=5999
replace ind = 8 if sic >= 6000 & sic <=6799
replace ind = 9 if sic >= 7000 & sic <=8999
replace ind = 10 if sic >= 9100 & sic <=9729
replace ind = 11 if sic >= 9900 & sic <= 9999

***************************** Regressions **************************************

gen gscpi_mps = L.gscpi*mps
sort gvkey date
xtset gvkey date

reghdfe invest mps L.gscpi gscpi_mps L.current L.salesg L.size L.ptoc L.rmptos L.dtoa L.age L.cap L.levg L.lqdty if ind == 1, absorb(gvkey) cluster(gvkey)
outreg2 using "tableA2.xml", replace se bdec(3) bracket label  
reghdfe invest mps L.gscpi gscpi_mps L.current L.salesg L.size L.ptoc L.rmptos L.dtoa L.age L.cap L.levg L.lqdty if ind == 2, absorb(gvkey) cluster(gvkey)
outreg2 using "tableA2.xml", append se bdec(3) bracket label 
reghdfe invest mps L.gscpi gscpi_mps L.current L.salesg L.size L.ptoc L.rmptos L.dtoa L.age L.cap L.levg L.lqdty if ind == 3, absorb(gvkey) cluster(gvkey)
outreg2 using "tableA2.xml", append se bdec(3) bracket label  
reghdfe invest mps L.gscpi gscpi_mps L.current L.salesg L.size L.ptoc L.rmptos L.dtoa L.age L.cap L.levg L.lqdty if ind == 4, absorb(gvkey) cluster(gvkey)
outreg2 using "tableA2.xml", append se bdec(3) bracket label  
reghdfe invest mps L.gscpi gscpi_mps L.current L.salesg L.size L.ptoc L.rmptos L.dtoa L.age L.cap L.levg L.lqdty if ind == 5, absorb(gvkey) cluster(gvkey)
outreg2 using "tableA2.xml", append se bdec(3) bracket label  
reghdfe invest mps L.gscpi gscpi_mps L.current L.salesg L.size L.ptoc L.rmptos L.dtoa L.age L.cap L.levg L.lqdty if ind == 6, absorb(gvkey) cluster(gvkey)
outreg2 using "tableA2.xml", append se bdec(3) bracket label  
reghdfe invest mps L.gscpi gscpi_mps L.current L.salesg L.size L.ptoc L.rmptos L.dtoa L.age L.cap L.levg L.lqdty if ind == 7, absorb(gvkey) cluster(gvkey)
outreg2 using "tableA2.xml", append se bdec(3) bracket label 
reghdfe invest mps L.gscpi gscpi_mps L.current L.salesg L.size L.ptoc L.rmptos L.dtoa L.age L.cap L.levg L.lqdty if ind == 8, absorb(gvkey) cluster(gvkey)
outreg2 using "tableA2.xml", append se bdec(3) bracket label  
reghdfe invest mps L.gscpi gscpi_mps L.current L.salesg L.size L.ptoc L.rmptos L.dtoa L.age L.cap L.levg L.lqdty if ind == 9, absorb(gvkey) cluster(gvkey)
outreg2 using "tableA2.xml", append se bdec(3) bracket label  
reghdfe invest mps L.gscpi gscpi_mps L.current L.salesg L.size L.ptoc L.rmptos L.dtoa L.age L.cap L.levg L.lqdty if ind == 11, absorb(gvkey) cluster(gvkey)
outreg2 using "tableA2.xml", append se bdec(3) bracket label  

********************************************************************************